
import bagsortsim.BagSortSim;


/**
 * DTU, Course 02224, Real-Time Systems
 * 
 * Example showing how to run Baggage Sorting Simulator
 * 
 * The Travellers thread shows how to automatically stimulate
 *   the simulation. 
 *
 */
public class Starter {

	public static void main(String[] args) {

		BagSortSim sim = BagSortSim.getSimulator();
		
		/* Start simulator and run control */
		sim.start();
		new Travellers(sim).start(); 
		Control.main(args);
	}

}

class Travellers extends Thread {
	
	BagSortSim sim;
	
	public Travellers (BagSortSim sim) {
		this.sim = sim;
		sim.setFeedCheck(true);
	}
	
	public void run() {
		try {
			while (true) {
				sleep((int) (Math.random()*5000));
				int counter = (Math.random() < 0.5 ? 1 : 2);
				int color   = (Math.random() < 0.6 ? BagSortSim.YELLOW  : BagSortSim.BLACK);
				sim.checkin(counter,color);
			}
		} catch (InterruptedException e) {}
	}
	
}


